package cn.emall.sso.controller;

import cn.emall.pojo.TbUser;
import cn.emall.sso.service.RegisterService;
import cn.emall.utils.EmallResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 用户注册Controller
 */
@Controller
public class RegisterController {

    @Autowired
    private RegisterService registerService;

    @RequestMapping("/page/register")
    public String toRegister(Model model){
        return "register";
    }

    @RequestMapping(value = "/user/check/{param}/{type}")
    @ResponseBody
    public EmallResult checkData(@PathVariable String param,@PathVariable Integer type){
        EmallResult result = registerService.checkData(param, type);
        return result;
    }

    @RequestMapping(value = "/user/register")
    @ResponseBody
    public EmallResult register(TbUser tbUser){
        EmallResult result = registerService.register(tbUser);
        return result;
    }
}
